<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
require('echarts/theme/macarons') // echarts theme
import resize from '@/components/Charts/mixins/resize'
export default {
  name: 'AuthComplexLineChart',
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '260px'
    }
  },
  data() {
    return {
      chart: null,
      value: []
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
      // this.getData()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = this.$echarts.init(this.$el, 'macarons')
      const initOption = {
        title: {
          show: true,
          text: '一周内认证统计',
          textStyle: {
            color: 'black'
          }
        },
        tooltip: {
          trigger: 'axis',
          backgroundColor: 'rgba(255,255,255,0.8)', // 设置背景图片 rgba格式
          color: 'black',
          borderWidth: '1', // 边框宽度设置1
          borderColor: 'gray', // 设置边框颜色
          textStyle: {
            color: 'black' // 设置文字颜色
          },
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {
          data: ['单口令', '单短信', '动态令牌', 'uKey','', '短信验证码结合口令', '占位1', '占位2'],
          right: 2,
          top: 0
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: ['2021/8/26', '2021/8/27', '2021/8/28', '2021/8/29', '2021/8/30', '2021/8/31', '2021/9/1']
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: '单口令',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: [320, 332, 301, 334, 390, 330, 320]
          },
          {
            name: '单短信',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: '动态令牌',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: [220, 182, 191, 234, 290, 330, 310]
          },
          {
            name: 'uKey',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: [150, 232, 201, 154, 190, 330, 410]
          },
          {
            name: '短信验证码结合口令',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: [862, 1018, 964, 1026, 1679, 1600, 1570]
          },
          {
            name: '占位1',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            stack: 'total',
            data: [620, 732, 701, 734, 1090, 1130, 1120]
          },
          {
            name: '占位2',
            type: 'bar',
            emphasis: {
              focus: 'series'
            },
            data: [120, 132, 101, 134, 290, 230, 220]
          }
        ]
      }
      this.chart.setOption(initOption)
    }
  }
}
</script>

<style scoped>

</style>
